<?php
/**                                          
 * 邀请记录
 * @author M2
 * @version 1.0
 * create Date 2013-04-27
 */
class InviteRecordModel extends Model {
	/**
	 * 获取用户邀请记录
	 * @param int $uid 用户ID
	 */
	public function getInviter($uid){
		$uid = intval($uid);
		$db_prefix = C('DB_PREFIX');
		$sql = "SELECT a.* FROM {$db_prefix}user as a,{$db_prefix}invite_record as b WHERE a.uid=b.uid AND b.fid=$uid";
		$result = $this->query($sql);
		return $result[0];
	}
	
	/**
	 * 设置用户邀请记录
	 * @param int $uid 用户ID
	 */
	public function setRecordValid($uid){
		$uid = intval($uid);
		$db_prefix = C('DB_PREFIX');
		$sql = "UPDATE {$db_prefix}invite_record SET valid=1 WHERE fid={$uid};";
		$result = $this->execute($sql);
		return $result;
	}
}
?>